package com.flower8.utils;

import java.io.*;

/**
 * @Description: 创建html工具类
 * @Author: tanglin
 * @Date: 2020/5/16 10:17
 * @Version: 1.0
 */
public class CreateHtmlUtil {

    /**
     * 动态创建html页面
     * @param channelNum
     * @param fileName
     * @param type
     * @return
     * @throws Exception
     */
    public static String createHtml(String channelNum,String fileName,int type)throws Exception {

        String strHtml = "";
        //创建模板一
        if(type == 1){
            strHtml = Mode1(channelNum);
        }else if(type == 2){

        }

        InputStream myIn=new ByteArrayInputStream(strHtml.getBytes());
        String url = ftpUtil.uploadHtml(myIn, fileName);
        System.out.println("访问地址："+url);

        return url;
    }

    /**
     * 页面模板1
     * @return
     */
    public static String Mode1(String channelNum){
        StringBuilder sb = new StringBuilder();
        sb.append("<!DOCTYPE html>\n" +
                "<html>\n" +
                "\t<head>\n" +
                "\t\t<meta charset=\"utf-8\" />\n" +
                "\t\t<meta http-equiv=\"Access-Control-Allow-Origin\" content=\"*\" />\n" +
                "\t\t<title>芭蕉花</title>\n" +
                "\t    <meta name=\"viewport\" content=\"width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0\">\n" +
                "\t    <link rel=\"stylesheet\" type=\"text/css\" href=\"css/regsiter.css\"/>\n" +
                "\t\t<link rel=\"stylesheet\" type=\"text/css\" href=\"css/index.css\"/>\n" +
                "\t\t<script src=\"./js/jquery-2.1.1.min.js\" type=\"text/javascript\"></script>\n" +
                "\t\t<script src=\"./js/index.js\" type=\"text/javascript\" ></script>\n" +
                "\t</head>\n" +
                "\t<body>\n" +
                "\t\t<div class=loginMain>\n" +
                "\t\t\t<div class=loginMainContent>\n" +
                "\t\t\t\t<img src=\"img/register.png\">\n" +
                "\t\t\t\t<img src=\"img/award.png\">\n" +
                "\t\t\t\t<div class=\"inputBox\">\n" +
                "\t\t\t\t\t<input type=\"hidden\" id=\"channelNum\" value='"+channelNum+"'/>\n" +
                "\t\t\t\t\t<input maxLength=\"11\" class=\"userMobile\" placeholder=\"请输入手机号码\" id=\"mobile\" name=\"mobile\"/> \n" +
                "\t\t\t\t</div>\n" +
                "\t\t\t\t<div class=\"inputBox\">\n" +
                "\t\t\t\t\t<input type=\"text\" class=\"code\" maxlength=\"6\" placeholder=\"请输入验证码\" id=\"code\" name=\"code\"/>\n" +
                "\t\t\t\t\t<span onclick=\"getCode()\" class=\"getCode\" id=\"msg\">获取验证码</span> \n" +
                "\t\t\t\t</div>\n" +
                "\t\t\t\t<button type=\"button\" class=\"btn\" onclick=\"checkMobile()\">提交</button>\n" +
                "\t\t\t\t<div  class=\"load\">下载即有机会领取</div>\n" +
                "\t\t\t</div>\n" +
                "\t\t</div>\n" +
                "\t</body>\n" +
                "</html>");
        return sb.toString();
    }
}
